// $ANTLR 3.3 Nov 30, 2010 12:45:30 C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g 2012-06-04 10:04:11

    package org.moflon.moca.rule.parser; 


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;


import org.antlr.runtime.tree.*;

public class RuleParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "WHITESPACE", "COMMENT", "TO", "DONTCARE", "THIS", "EMPTY", "SEPARATOR", "NEWLINE", "OPENPAR", "CLOSEPAR", "RULE", "BEFORE", "AFTER", "ROW", "DONTCARE_FIELD", "THIS_FIELD", "EMPTY_FIELD", "MAIN"
    };
    public static final int EOF=-1;
    public static final int WHITESPACE=4;
    public static final int COMMENT=5;
    public static final int TO=6;
    public static final int DONTCARE=7;
    public static final int THIS=8;
    public static final int EMPTY=9;
    public static final int SEPARATOR=10;
    public static final int NEWLINE=11;
    public static final int OPENPAR=12;
    public static final int CLOSEPAR=13;
    public static final int RULE=14;
    public static final int BEFORE=15;
    public static final int AFTER=16;
    public static final int ROW=17;
    public static final int DONTCARE_FIELD=18;
    public static final int THIS_FIELD=19;
    public static final int EMPTY_FIELD=20;
    public static final int MAIN=21;

    // delegates
    // delegators


        public RuleParser(TokenStream input) {
            this(input, new RecognizerSharedState());
        }
        public RuleParser(TokenStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        
    protected TreeAdaptor adaptor = new CommonTreeAdaptor();

    public void setTreeAdaptor(TreeAdaptor adaptor) {
        this.adaptor = adaptor;
    }
    public TreeAdaptor getTreeAdaptor() {
        return adaptor;
    }

    public String[] getTokenNames() { return RuleParser.tokenNames; }
    public String getGrammarFileName() { return "C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g"; }


    public static class main_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "main"
    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:1: main : ( comment | ( rule NEWLINE ( NEWLINE )+ ) )* rule -> ^( MAIN ( rule )* ) ;
    public final RuleParser.main_return main() throws RecognitionException {
        RuleParser.main_return retval = new RuleParser.main_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token NEWLINE3=null;
        Token NEWLINE4=null;
        RuleParser.comment_return comment1 = null;

        RuleParser.rule_return rule2 = null;

        RuleParser.rule_return rule5 = null;


        Object NEWLINE3_tree=null;
        Object NEWLINE4_tree=null;
        RewriteRuleTokenStream stream_NEWLINE=new RewriteRuleTokenStream(adaptor,"token NEWLINE");
        RewriteRuleSubtreeStream stream_rule=new RewriteRuleSubtreeStream(adaptor,"rule rule");
        RewriteRuleSubtreeStream stream_comment=new RewriteRuleSubtreeStream(adaptor,"rule comment");
        try {
            // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:5: ( ( comment | ( rule NEWLINE ( NEWLINE )+ ) )* rule -> ^( MAIN ( rule )* ) )
            // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:7: ( comment | ( rule NEWLINE ( NEWLINE )+ ) )* rule
            {
            // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:7: ( comment | ( rule NEWLINE ( NEWLINE )+ ) )*
            loop2:
            do {
                int alt2=3;
                alt2 = dfa2.predict(input);
                switch (alt2) {
            	case 1 :
            	    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:8: comment
            	    {
            	    pushFollow(FOLLOW_comment_in_main52);
            	    comment1=comment();

            	    state._fsp--;

            	    stream_comment.add(comment1.getTree());

            	    }
            	    break;
            	case 2 :
            	    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:18: ( rule NEWLINE ( NEWLINE )+ )
            	    {
            	    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:18: ( rule NEWLINE ( NEWLINE )+ )
            	    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:19: rule NEWLINE ( NEWLINE )+
            	    {
            	    pushFollow(FOLLOW_rule_in_main57);
            	    rule2=rule();

            	    state._fsp--;

            	    stream_rule.add(rule2.getTree());
            	    NEWLINE3=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_main59);  
            	    stream_NEWLINE.add(NEWLINE3);

            	    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:32: ( NEWLINE )+
            	    int cnt1=0;
            	    loop1:
            	    do {
            	        int alt1=2;
            	        int LA1_0 = input.LA(1);

            	        if ( (LA1_0==NEWLINE) ) {
            	            alt1=1;
            	        }


            	        switch (alt1) {
            	    	case 1 :
            	    	    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:32: NEWLINE
            	    	    {
            	    	    NEWLINE4=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_main61);  
            	    	    stream_NEWLINE.add(NEWLINE4);


            	    	    }
            	    	    break;

            	    	default :
            	    	    if ( cnt1 >= 1 ) break loop1;
            	                EarlyExitException eee =
            	                    new EarlyExitException(1, input);
            	                throw eee;
            	        }
            	        cnt1++;
            	    } while (true);


            	    }


            	    }
            	    break;

            	default :
            	    break loop2;
                }
            } while (true);

            pushFollow(FOLLOW_rule_in_main67);
            rule5=rule();

            state._fsp--;

            stream_rule.add(rule5.getTree());


            // AST REWRITE
            // elements: rule
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 15:49: -> ^( MAIN ( rule )* )
            {
                // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:52: ^( MAIN ( rule )* )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(MAIN, "MAIN"), root_1);

                // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:15:59: ( rule )*
                while ( stream_rule.hasNext() ) {
                    adaptor.addChild(root_1, stream_rule.nextTree());

                }
                stream_rule.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "main"

    public static class comment_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "comment"
    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:17:1: comment : COMMENT ( NEWLINE )* ;
    public final RuleParser.comment_return comment() throws RecognitionException {
        RuleParser.comment_return retval = new RuleParser.comment_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token COMMENT6=null;
        Token NEWLINE7=null;

        Object COMMENT6_tree=null;
        Object NEWLINE7_tree=null;

        try {
            // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:17:8: ( COMMENT ( NEWLINE )* )
            // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:17:10: COMMENT ( NEWLINE )*
            {
            root_0 = (Object)adaptor.nil();

            COMMENT6=(Token)match(input,COMMENT,FOLLOW_COMMENT_in_comment83); 
            COMMENT6_tree = (Object)adaptor.create(COMMENT6);
            adaptor.addChild(root_0, COMMENT6_tree);

            // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:17:18: ( NEWLINE )*
            loop3:
            do {
                int alt3=2;
                int LA3_0 = input.LA(1);

                if ( (LA3_0==NEWLINE) ) {
                    alt3=1;
                }


                switch (alt3) {
            	case 1 :
            	    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:17:18: NEWLINE
            	    {
            	    NEWLINE7=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_comment85); 
            	    NEWLINE7_tree = (Object)adaptor.create(NEWLINE7);
            	    adaptor.addChild(root_0, NEWLINE7_tree);


            	    }
            	    break;

            	default :
            	    break loop3;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "comment"

    public static class rule_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "rule"
    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:19:1: rule : lhs= pattern NEWLINE TO NEWLINE rhs= pattern -> ^( RULE ^( BEFORE $lhs) ^( AFTER $rhs) ) ;
    public final RuleParser.rule_return rule() throws RecognitionException {
        RuleParser.rule_return retval = new RuleParser.rule_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token NEWLINE8=null;
        Token TO9=null;
        Token NEWLINE10=null;
        RuleParser.pattern_return lhs = null;

        RuleParser.pattern_return rhs = null;


        Object NEWLINE8_tree=null;
        Object TO9_tree=null;
        Object NEWLINE10_tree=null;
        RewriteRuleTokenStream stream_NEWLINE=new RewriteRuleTokenStream(adaptor,"token NEWLINE");
        RewriteRuleTokenStream stream_TO=new RewriteRuleTokenStream(adaptor,"token TO");
        RewriteRuleSubtreeStream stream_pattern=new RewriteRuleSubtreeStream(adaptor,"rule pattern");
        try {
            // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:19:5: (lhs= pattern NEWLINE TO NEWLINE rhs= pattern -> ^( RULE ^( BEFORE $lhs) ^( AFTER $rhs) ) )
            // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:19:7: lhs= pattern NEWLINE TO NEWLINE rhs= pattern
            {
            pushFollow(FOLLOW_pattern_in_rule95);
            lhs=pattern();

            state._fsp--;

            stream_pattern.add(lhs.getTree());
            NEWLINE8=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_rule97);  
            stream_NEWLINE.add(NEWLINE8);

            TO9=(Token)match(input,TO,FOLLOW_TO_in_rule99);  
            stream_TO.add(TO9);

            NEWLINE10=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_rule101);  
            stream_NEWLINE.add(NEWLINE10);

            pushFollow(FOLLOW_pattern_in_rule105);
            rhs=pattern();

            state._fsp--;

            stream_pattern.add(rhs.getTree());


            // AST REWRITE
            // elements: lhs, rhs
            // token labels: 
            // rule labels: retval, rhs, lhs
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
            RewriteRuleSubtreeStream stream_rhs=new RewriteRuleSubtreeStream(adaptor,"rule rhs",rhs!=null?rhs.tree:null);
            RewriteRuleSubtreeStream stream_lhs=new RewriteRuleSubtreeStream(adaptor,"rule lhs",lhs!=null?lhs.tree:null);

            root_0 = (Object)adaptor.nil();
            // 19:50: -> ^( RULE ^( BEFORE $lhs) ^( AFTER $rhs) )
            {
                // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:19:53: ^( RULE ^( BEFORE $lhs) ^( AFTER $rhs) )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(RULE, "RULE"), root_1);

                // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:19:60: ^( BEFORE $lhs)
                {
                Object root_2 = (Object)adaptor.nil();
                root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(BEFORE, "BEFORE"), root_2);

                adaptor.addChild(root_2, stream_lhs.nextTree());

                adaptor.addChild(root_1, root_2);
                }
                // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:19:75: ^( AFTER $rhs)
                {
                Object root_2 = (Object)adaptor.nil();
                root_2 = (Object)adaptor.becomeRoot((Object)adaptor.create(AFTER, "AFTER"), root_2);

                adaptor.addChild(root_2, stream_rhs.nextTree());

                adaptor.addChild(root_1, root_2);
                }

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "rule"

    public static class pattern_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "pattern"
    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:21:1: pattern : ( row NEWLINE )* row -> ( row )+ ;
    public final RuleParser.pattern_return pattern() throws RecognitionException {
        RuleParser.pattern_return retval = new RuleParser.pattern_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token NEWLINE12=null;
        RuleParser.row_return row11 = null;

        RuleParser.row_return row13 = null;


        Object NEWLINE12_tree=null;
        RewriteRuleTokenStream stream_NEWLINE=new RewriteRuleTokenStream(adaptor,"token NEWLINE");
        RewriteRuleSubtreeStream stream_row=new RewriteRuleSubtreeStream(adaptor,"rule row");
        try {
            // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:21:8: ( ( row NEWLINE )* row -> ( row )+ )
            // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:21:10: ( row NEWLINE )* row
            {
            // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:21:10: ( row NEWLINE )*
            loop4:
            do {
                int alt4=2;
                alt4 = dfa4.predict(input);
                switch (alt4) {
            	case 1 :
            	    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:21:11: row NEWLINE
            	    {
            	    pushFollow(FOLLOW_row_in_pattern133);
            	    row11=row();

            	    state._fsp--;

            	    stream_row.add(row11.getTree());
            	    NEWLINE12=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_pattern135);  
            	    stream_NEWLINE.add(NEWLINE12);


            	    }
            	    break;

            	default :
            	    break loop4;
                }
            } while (true);

            pushFollow(FOLLOW_row_in_pattern139);
            row13=row();

            state._fsp--;

            stream_row.add(row13.getTree());


            // AST REWRITE
            // elements: row
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 21:29: -> ( row )+
            {
                if ( !(stream_row.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_row.hasNext() ) {
                    adaptor.addChild(root_0, stream_row.nextTree());

                }
                stream_row.reset();

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "pattern"

    public static class row_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "row"
    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:23:1: row : ( tile SEPARATOR )* tile -> ^( ROW ( tile )+ ) ;
    public final RuleParser.row_return row() throws RecognitionException {
        RuleParser.row_return retval = new RuleParser.row_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token SEPARATOR15=null;
        RuleParser.tile_return tile14 = null;

        RuleParser.tile_return tile16 = null;


        Object SEPARATOR15_tree=null;
        RewriteRuleTokenStream stream_SEPARATOR=new RewriteRuleTokenStream(adaptor,"token SEPARATOR");
        RewriteRuleSubtreeStream stream_tile=new RewriteRuleSubtreeStream(adaptor,"rule tile");
        try {
            // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:23:4: ( ( tile SEPARATOR )* tile -> ^( ROW ( tile )+ ) )
            // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:23:6: ( tile SEPARATOR )* tile
            {
            // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:23:6: ( tile SEPARATOR )*
            loop5:
            do {
                int alt5=2;
                switch ( input.LA(1) ) {
                case THIS:
                    {
                    int LA5_1 = input.LA(2);

                    if ( (LA5_1==SEPARATOR) ) {
                        alt5=1;
                    }


                    }
                    break;
                case DONTCARE:
                    {
                    int LA5_2 = input.LA(2);

                    if ( (LA5_2==SEPARATOR) ) {
                        alt5=1;
                    }


                    }
                    break;
                case EMPTY:
                    {
                    int LA5_3 = input.LA(2);

                    if ( (LA5_3==SEPARATOR) ) {
                        alt5=1;
                    }


                    }
                    break;

                }

                switch (alt5) {
            	case 1 :
            	    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:23:7: tile SEPARATOR
            	    {
            	    pushFollow(FOLLOW_tile_in_row152);
            	    tile14=tile();

            	    state._fsp--;

            	    stream_tile.add(tile14.getTree());
            	    SEPARATOR15=(Token)match(input,SEPARATOR,FOLLOW_SEPARATOR_in_row154);  
            	    stream_SEPARATOR.add(SEPARATOR15);


            	    }
            	    break;

            	default :
            	    break loop5;
                }
            } while (true);

            pushFollow(FOLLOW_tile_in_row158);
            tile16=tile();

            state._fsp--;

            stream_tile.add(tile16.getTree());


            // AST REWRITE
            // elements: tile
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (Object)adaptor.nil();
            // 23:29: -> ^( ROW ( tile )+ )
            {
                // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:23:32: ^( ROW ( tile )+ )
                {
                Object root_1 = (Object)adaptor.nil();
                root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(ROW, "ROW"), root_1);

                if ( !(stream_tile.hasNext()) ) {
                    throw new RewriteEarlyExitException();
                }
                while ( stream_tile.hasNext() ) {
                    adaptor.addChild(root_1, stream_tile.nextTree());

                }
                stream_tile.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "row"

    public static class tile_return extends ParserRuleReturnScope {
        Object tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "tile"
    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:26:1: tile : ( THIS -> ^( THIS_FIELD ) | DONTCARE -> ^( DONTCARE_FIELD ) | EMPTY -> ^( EMPTY_FIELD ) );
    public final RuleParser.tile_return tile() throws RecognitionException {
        RuleParser.tile_return retval = new RuleParser.tile_return();
        retval.start = input.LT(1);

        Object root_0 = null;

        Token THIS17=null;
        Token DONTCARE18=null;
        Token EMPTY19=null;

        Object THIS17_tree=null;
        Object DONTCARE18_tree=null;
        Object EMPTY19_tree=null;
        RewriteRuleTokenStream stream_DONTCARE=new RewriteRuleTokenStream(adaptor,"token DONTCARE");
        RewriteRuleTokenStream stream_EMPTY=new RewriteRuleTokenStream(adaptor,"token EMPTY");
        RewriteRuleTokenStream stream_THIS=new RewriteRuleTokenStream(adaptor,"token THIS");

        try {
            // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:26:5: ( THIS -> ^( THIS_FIELD ) | DONTCARE -> ^( DONTCARE_FIELD ) | EMPTY -> ^( EMPTY_FIELD ) )
            int alt6=3;
            switch ( input.LA(1) ) {
            case THIS:
                {
                alt6=1;
                }
                break;
            case DONTCARE:
                {
                alt6=2;
                }
                break;
            case EMPTY:
                {
                alt6=3;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 6, 0, input);

                throw nvae;
            }

            switch (alt6) {
                case 1 :
                    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:26:7: THIS
                    {
                    THIS17=(Token)match(input,THIS,FOLLOW_THIS_in_tile175);  
                    stream_THIS.add(THIS17);



                    // AST REWRITE
                    // elements: 
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 26:12: -> ^( THIS_FIELD )
                    {
                        // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:26:15: ^( THIS_FIELD )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(THIS_FIELD, "THIS_FIELD"), root_1);

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 2 :
                    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:26:31: DONTCARE
                    {
                    DONTCARE18=(Token)match(input,DONTCARE,FOLLOW_DONTCARE_in_tile185);  
                    stream_DONTCARE.add(DONTCARE18);



                    // AST REWRITE
                    // elements: 
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 26:40: -> ^( DONTCARE_FIELD )
                    {
                        // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:26:43: ^( DONTCARE_FIELD )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(DONTCARE_FIELD, "DONTCARE_FIELD"), root_1);

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;
                case 3 :
                    // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:26:63: EMPTY
                    {
                    EMPTY19=(Token)match(input,EMPTY,FOLLOW_EMPTY_in_tile195);  
                    stream_EMPTY.add(EMPTY19);



                    // AST REWRITE
                    // elements: 
                    // token labels: 
                    // rule labels: retval
                    // token list labels: 
                    // rule list labels: 
                    // wildcard labels: 
                    retval.tree = root_0;
                    RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

                    root_0 = (Object)adaptor.nil();
                    // 26:69: -> ^( EMPTY_FIELD )
                    {
                        // C:\\Users\\roland\\mbse_workspace_ex2\\BoardGame\\src\\org\\moflon\\moca\\rule\\parser\\RuleParser.g:26:72: ^( EMPTY_FIELD )
                        {
                        Object root_1 = (Object)adaptor.nil();
                        root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(EMPTY_FIELD, "EMPTY_FIELD"), root_1);

                        adaptor.addChild(root_0, root_1);
                        }

                    }

                    retval.tree = root_0;
                    }
                    break;

            }
            retval.stop = input.LT(-1);

            retval.tree = (Object)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "tile"

    // Delegated rules


    protected DFA2 dfa2 = new DFA2(this);
    protected DFA4 dfa4 = new DFA4(this);
    static final String DFA2_eotS =
        "\20\uffff";
    static final String DFA2_eofS =
        "\11\uffff\3\16\4\uffff";
    static final String DFA2_minS =
        "\1\5\3\12\1\uffff\1\7\1\6\1\13\1\7\3\12\2\7\2\uffff";
    static final String DFA2_maxS =
        "\1\11\3\13\1\uffff\2\11\1\13\1\11\3\13\1\11\1\13\2\uffff";
    static final String DFA2_acceptS =
        "\4\uffff\1\1\11\uffff\1\3\1\2";
    static final String DFA2_specialS =
        "\20\uffff}>";
    static final String[] DFA2_transitionS = {
            "\1\4\1\uffff\1\2\1\1\1\3",
            "\1\5\1\6",
            "\1\5\1\6",
            "\1\5\1\6",
            "",
            "\1\2\1\1\1\3",
            "\1\7\1\2\1\1\1\3",
            "\1\10",
            "\1\12\1\11\1\13",
            "\1\14\1\15",
            "\1\14\1\15",
            "\1\14\1\15",
            "\1\12\1\11\1\13",
            "\1\12\1\11\1\13\1\uffff\1\17",
            "",
            ""
    };

    static final short[] DFA2_eot = DFA.unpackEncodedString(DFA2_eotS);
    static final short[] DFA2_eof = DFA.unpackEncodedString(DFA2_eofS);
    static final char[] DFA2_min = DFA.unpackEncodedStringToUnsignedChars(DFA2_minS);
    static final char[] DFA2_max = DFA.unpackEncodedStringToUnsignedChars(DFA2_maxS);
    static final short[] DFA2_accept = DFA.unpackEncodedString(DFA2_acceptS);
    static final short[] DFA2_special = DFA.unpackEncodedString(DFA2_specialS);
    static final short[][] DFA2_transition;

    static {
        int numStates = DFA2_transitionS.length;
        DFA2_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA2_transition[i] = DFA.unpackEncodedString(DFA2_transitionS[i]);
        }
    }

    class DFA2 extends DFA {

        public DFA2(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 2;
            this.eot = DFA2_eot;
            this.eof = DFA2_eof;
            this.min = DFA2_min;
            this.max = DFA2_max;
            this.accept = DFA2_accept;
            this.special = DFA2_special;
            this.transition = DFA2_transition;
        }
        public String getDescription() {
            return "()* loopback of 15:7: ( comment | ( rule NEWLINE ( NEWLINE )+ ) )*";
        }
    }
    static final String DFA4_eotS =
        "\10\uffff";
    static final String DFA4_eofS =
        "\1\uffff\3\6\4\uffff";
    static final String DFA4_minS =
        "\1\7\3\12\1\7\1\6\2\uffff";
    static final String DFA4_maxS =
        "\1\11\3\13\1\11\1\13\2\uffff";
    static final String DFA4_acceptS =
        "\6\uffff\1\2\1\1";
    static final String DFA4_specialS =
        "\10\uffff}>";
    static final String[] DFA4_transitionS = {
            "\1\2\1\1\1\3",
            "\1\4\1\5",
            "\1\4\1\5",
            "\1\4\1\5",
            "\1\2\1\1\1\3",
            "\1\6\3\7\1\uffff\1\6",
            "",
            ""
    };

    static final short[] DFA4_eot = DFA.unpackEncodedString(DFA4_eotS);
    static final short[] DFA4_eof = DFA.unpackEncodedString(DFA4_eofS);
    static final char[] DFA4_min = DFA.unpackEncodedStringToUnsignedChars(DFA4_minS);
    static final char[] DFA4_max = DFA.unpackEncodedStringToUnsignedChars(DFA4_maxS);
    static final short[] DFA4_accept = DFA.unpackEncodedString(DFA4_acceptS);
    static final short[] DFA4_special = DFA.unpackEncodedString(DFA4_specialS);
    static final short[][] DFA4_transition;

    static {
        int numStates = DFA4_transitionS.length;
        DFA4_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA4_transition[i] = DFA.unpackEncodedString(DFA4_transitionS[i]);
        }
    }

    class DFA4 extends DFA {

        public DFA4(BaseRecognizer recognizer) {
            this.recognizer = recognizer;
            this.decisionNumber = 4;
            this.eot = DFA4_eot;
            this.eof = DFA4_eof;
            this.min = DFA4_min;
            this.max = DFA4_max;
            this.accept = DFA4_accept;
            this.special = DFA4_special;
            this.transition = DFA4_transition;
        }
        public String getDescription() {
            return "()* loopback of 21:10: ( row NEWLINE )*";
        }
    }
 

    public static final BitSet FOLLOW_comment_in_main52 = new BitSet(new long[]{0x00000000000003A0L});
    public static final BitSet FOLLOW_rule_in_main57 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_NEWLINE_in_main59 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_NEWLINE_in_main61 = new BitSet(new long[]{0x0000000000000BA0L});
    public static final BitSet FOLLOW_rule_in_main67 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_COMMENT_in_comment83 = new BitSet(new long[]{0x0000000000000802L});
    public static final BitSet FOLLOW_NEWLINE_in_comment85 = new BitSet(new long[]{0x0000000000000802L});
    public static final BitSet FOLLOW_pattern_in_rule95 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_NEWLINE_in_rule97 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_TO_in_rule99 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_NEWLINE_in_rule101 = new BitSet(new long[]{0x0000000000000380L});
    public static final BitSet FOLLOW_pattern_in_rule105 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_row_in_pattern133 = new BitSet(new long[]{0x0000000000000800L});
    public static final BitSet FOLLOW_NEWLINE_in_pattern135 = new BitSet(new long[]{0x0000000000000380L});
    public static final BitSet FOLLOW_row_in_pattern139 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_tile_in_row152 = new BitSet(new long[]{0x0000000000000400L});
    public static final BitSet FOLLOW_SEPARATOR_in_row154 = new BitSet(new long[]{0x0000000000000380L});
    public static final BitSet FOLLOW_tile_in_row158 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_THIS_in_tile175 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_DONTCARE_in_tile185 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_EMPTY_in_tile195 = new BitSet(new long[]{0x0000000000000002L});

}